//
//  BCGotCommitChooseV.m
//  BangcaiDriver
//
//  Created by apple on 16/9/20.
//  Copyright © 2016年 BC. All rights reserved.
//

#import "BCGotCommitChooseV.h"
@interface BCGotCommitChooseV ()
{
    UILabel *date_y;
    UILabel *date_t;
    UILabel *date;
    
    UILabel *dan_y;
    UILabel *dan_t;
    UILabel *dan;
    
    UILabel *amount_y;
    UILabel *amount_t;
    UILabel *amount;
    
    UILabel *leftLine;
    UILabel *rightLine;
    UILabel *bottomLine;

}

@end

@implementation BCGotCommitChooseV

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

- (void)createView
{
    self.style = 1;
    date_y = [[UILabel alloc] init];
    date_t = [[UILabel alloc] init];
    date = [[UILabel alloc] init];
    dan_y = [[UILabel alloc] init];
    dan_t = [[UILabel alloc] init];
    dan = [[UILabel alloc] init];
    amount_y = [[UILabel alloc] init];
    amount_t = [[UILabel alloc] init];
    amount = [[UILabel alloc] init];
    leftLine = [[UILabel alloc] init];
    rightLine = [[UILabel alloc] init];
    bottomLine = [[UILabel alloc] init];
    self.leftButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.midButton = [UIButton buttonWithType:UIButtonTypeSystem];
    self.rightButton = [UIButton buttonWithType:UIButtonTypeSystem];
    [self addSubview:self.leftButton];
    [self addSubview:self.midButton];
    [self addSubview:self.rightButton];
    [self addSubview:date_t];
    [self addSubview:date_y];
    [self addSubview:date];
    [self addSubview:dan];
    [self addSubview:dan_t];
    [self addSubview:dan_y];
    [self addSubview:amount];
    [self addSubview:amount_t];
    [self addSubview:amount_y];
    [self addSubview:leftLine];
    [self addSubview:rightLine];
    [self addSubview:bottomLine];
    date_y.text = @"昨天";
    date_y.font = [UIFont boldSystemFontOfSize:16];
    date.text = @"今天";
    date.font = [UIFont boldSystemFontOfSize:16];
    date_t.text = @"明天";
    date_t.font = [UIFont boldSystemFontOfSize:16];
    dan_y.text = @"单";
    dan_y.font = [UIFont boldSystemFontOfSize:16];
    dan_t.text = @"单";
    dan_t.font = [UIFont boldSystemFontOfSize:16];
    dan.text = @"单";
    dan.font = [UIFont boldSystemFontOfSize:16];
    
    
    amount.text = [NSString stringWithFormat:@"1%ld", self.m_amount];
    amount.font = [UIFont systemFontOfSize:42];
    amount_y.text = [NSString stringWithFormat:@"2%ld", self.y_amount];
    amount_y.font = [UIFont systemFontOfSize:42];
    amount_t.text = [NSString stringWithFormat:@"3%ld", self.t_amount];
    amount_t.font = [UIFont systemFontOfSize:42];

    amount_t.textColor = [UIColor blackColor];
    amount_y.textColor = [UIColor blackColor];
    dan_t.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    dan_y.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_t.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_y.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date.textColor = BangcaiOrange;
    amount.textColor = BangcaiOrange;
    dan.textColor = BangcaiOrange;
    leftLine.backgroundColor = [UIColor colorWithRed:0.823 green:0.824 blue:0.823 alpha:1];
    rightLine.backgroundColor = [UIColor colorWithRed:0.823 green:0.824 blue:0.823 alpha:1];
    bottomLine.backgroundColor = [UIColor colorWithRed:0.950 green:0.950 blue:0.950 alpha:1];
    self.leftButton.backgroundColor = [UIColor clearColor];
    self.rightButton.backgroundColor = [UIColor clearColor];
    self.midButton.backgroundColor = [UIColor clearColor];
    [self.leftButton addTarget:self action:@selector(changeColor_l:) forControlEvents:UIControlEventTouchUpInside];
    [self.rightButton addTarget:self action:@selector(changeColor_r:) forControlEvents:UIControlEventTouchUpInside];
    [self.midButton addTarget:self action:@selector(changeColor_m:) forControlEvents:UIControlEventTouchUpInside];
    [date mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.top.mas_equalTo(10);
    }];
    
    [date_y mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(60);
        make.top.mas_equalTo(10);
        
    }];
    
    [date_t mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-60);
        make.top.mas_equalTo(10);
    }];
    
    [amount mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(date);
        make.top.mas_equalTo(date.mas_bottom);
        
    }];
    [amount_t mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(date_t);
        make.top.mas_equalTo(date_t.mas_bottom);
        
    }];
    [amount_y mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.equalTo(date_y);
        make.top.mas_equalTo(date_y.mas_bottom);
        
    }];
    
    [dan mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(amount.mas_right).with.offset(4);
        make.bottom.equalTo(amount).with.offset(-8);
        
    }];
    [dan_t mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(amount_t.mas_right).with.offset(4);
        make.bottom.equalTo(amount_t).with.offset(-8);
        
    }];
    [dan_y mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(amount_y.mas_right).with.offset(4);
        make.bottom.equalTo(amount_y).with.offset(-8);
        
    }];
    
    [leftLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(SCREEN_WIDTH / 3);
        make.width.mas_equalTo(1);
        make.height.mas_equalTo(60);
        make.centerY.mas_equalTo(0);
        
    }];
    
    [rightLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(SCREEN_WIDTH / 3 * 2);
        make.width.mas_equalTo(1);
        make.height.mas_equalTo(60);
        make.centerY.mas_equalTo(0);

    }];
    
    [bottomLine mas_makeConstraints:^(MASConstraintMaker *make) {
        make.bottom.mas_equalTo(0);
        make.height.mas_equalTo(1);
        make.width.mas_equalTo(SCREEN_WIDTH);
        
    }];

    [self.leftButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH / 3);
        make.top.mas_equalTo(0);
        make.height.equalTo(self);
    }];
    [self.midButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.centerX.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH / 3);
        make.top.mas_equalTo(0);
        make.height.equalTo(self);
        
    }];
    [self.rightButton mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(0);
        make.width.mas_equalTo(SCREEN_WIDTH / 3);
        make.top.mas_equalTo(0);
        make.height.equalTo(self);
        
    }];

    
    
}

- (void)changeColor_l:(UIButton*)but
{
    self.style = 0;
    amount_t.textColor = [UIColor blackColor];
    amount_y.textColor = BangcaiOrange;
    amount.textColor = [UIColor blackColor];
    dan_t.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    dan_y.textColor = BangcaiOrange;
    dan.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_t.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_y.textColor = BangcaiOrange;
    date.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];

    [self.delegate chooseDate:self.style];
}
- (void)changeColor_r:(UIButton*)but
{
    self.style = 1;
    amount_t.textColor =BangcaiOrange;
    amount_y.textColor = [UIColor blackColor];
    amount.textColor = [UIColor blackColor];
    dan_t.textColor = BangcaiOrange;
    dan_y.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    dan.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_t.textColor = BangcaiOrange;
    date_y.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    [self.delegate chooseDate:self.style];


}- (void)changeColor_m:(UIButton*)but
{
    self.style = 2;
    amount_t.textColor = [UIColor blackColor];
    amount_y.textColor = [UIColor blackColor];
    dan_t.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    dan_y.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_t.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date_y.textColor = [UIColor colorWithRed:0.518 green:0.518 blue:0.518 alpha:1];
    date.textColor = BangcaiOrange;
    amount.textColor = BangcaiOrange;
    dan.textColor = BangcaiOrange;
    [self.delegate chooseDate:self.style];

}

@end
